﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading.Tasks;
using WisDom.Models;
using WisDom.Utils;

namespace WisDom.IService
{
    /// <summary>
    /// 数据源的接口
    /// </summary>
    public interface IBaseDataInterface<T> where T : class, new()
    {
        #region 获取数据
        /// <summary>
        /// 获取数据列表
        /// </summary>
        /// <param name="queryJson">查询条件</param>
        /// <returns></returns>
        Task<List<T>> GetList(string queryJson);

        /// <summary>
        /// 获取分页的数据列表
        /// </summary>
        /// <param name="pagination">分页对象</param>
        /// <param name="queryJson">查询条件</param>
        /// <returns></returns>
        Task<List<T>> GetPageList(Pagination pagination, string queryJson);

        /// <summary>
        /// 获取分页的DataTable
        /// </summary>
        /// <param name="pagination">分页对象</param>
        /// <param name="queryJson">查询条件</param>
        /// <returns></returns>
        Task<DataTable> GetPageDataTable(Pagination pagination, string queryJson);

        /// <summary>
        /// 获取单个实体
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <returns></returns>
        Task<T> GetEntity(string keyValue);
        #endregion

        #region 保存数据
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="keyValue"></param>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<bool> SaveForm(string keyValue, T entity);

        /// <summary>
        /// 移除数据
        /// </summary>
        /// <param name="keyValue"></param>
        /// <returns></returns>
        Task RemoveForm(string keyValue);

        #endregion

    }
}
